package com.mxpio.erp.common.jpa.model;

import java.math.BigDecimal;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;

import com.mxpio.erp.common.inventory.entity.Warehouse;
import com.mxpio.erp.common.technology.entity.ItemGroup;
import com.mxpioframework.security.annotation.Dict;
import com.mxpioframework.security.entity.BaseEntity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

@Data
@MappedSuperclass
@EqualsAndHashCode(callSuper=false)
@IdClass(OrderLineKey.class)
public class OrderLine extends BaseEntity {

	private static final long serialVersionUID = 1L;

	/*@EmbeddedId
	private BizOrderLineKey id;*/

	@Column(name = "LINE_NO_", updatable = false)
	@Schema(description = "行号")
	@Id
	private String lineNo;

	@Column(name = "BIZ_NO_", updatable = false)
	@Schema(description = "业务单号")
	@Id
	private String bizNo;

	@Column(name = "CLOSE_STATUS_")
	@Schema(description = "关闭状态")
	@Dict(dicCode="ERP_COMMON_CLOSE_STATUS")
	private String closeStatus;

	@Column(name = "SORT_")
	@Schema(description = "顺序号")
	private String sort;
	
	@Column(name = "ITEM_CODE_")
	@Schema(description = "物料代码")
	private String itemCode;

	@Column(name = "ITEM_GROUP_CODE_")
	@Schema(description = "物料组")
	@Dict(dicCode = "groupCode", dicEntity = ItemGroup.class, dicText = "groupName")
	private String itemGroupCode;


	@Column(name = "ITEM_NAME_")
	@Schema(description = "物料名称")
	private String itemName ;

	@Column(name = "ITEM_SPEC_")
	@Schema(description = "规格型号")
	private String itemSpec;
	
	@Column(name = "WH_CODE_")
	@Schema(description = "入库仓库")
	@Dict(dicCode = "whCode" ,dicEntity = Warehouse.class, dicText = "whName")
	private String whCode;
	
	@Column(name = "QUANTITY_")
	@Schema(description = "数量")
	private BigDecimal quantity;
	
	@Column(name = "LOT_NO_")
	@Schema(description = "批次号")
	private String lotNo;

	@Column(name = "SUB_LOT_INDEX_")
	@Schema(description = "子批次索引号")
	private String subLotIndex;

	@Column(name = "UNIT_CODE_")
    @Schema(description = "单位编号")
	@Dict(dicCode="ERP_TECH_UNIT_CODE")
    private String unitCode;

	@Column(name = "DRAWING_NO_")
	@Schema(description = "图号")
	private String drawingNo;

	@Transient
	@Schema(description = "已执行数量")
	private BigDecimal actualQuantity;
	
	@Transient
	@Schema(description = "已执行退货数量")
	private BigDecimal actualRejectQuantity;
	
	@Transient
	@Schema(description = "计划执行数量")
	private BigDecimal planQuantity;
	
	@Transient
	@Schema(description = "计划退货数量")
	private BigDecimal planRejectQuantity;

	@Transient
	@Schema(description = "允差范围数量")
	private BigDecimal toleranceRangeQuantity;
}
